package climbingHills;

/**
 * Class TrackPoint represents one trackpoint in gpx file, which looks like: 
 * <trkpt lat="50.058252" lon="13.99518">
 *       <ele>479.3</ele>
 *       <time>2012-05-27T07:33:36Z</time>
 * </trkpt>	
 * @author Josef Vermach
 */
public class TrackPoint {
	public double lat; //latitude
	public double lon; //longitude
	public double ele; //elevation
	String slat; //string latitude
	String slon; //string longitude
	String sele; //string elevation

	public TrackPoint (String s){
		int i, j;
		i = s.indexOf("lat");
		j = s.indexOf(" lon");
		this.slat = (String) s.subSequence(i+5,j-1);
		i = s.indexOf("lon");
		j = s.indexOf(">");
		this.slon = (String) s.subSequence(i+5,j-1);
		

		this.lat = Double.valueOf(this.slat);
		this.lon = Double.valueOf(this.slon);

	}
	
	public void addEle(String s){
		int i, j;
		i = s.indexOf("<ele>");
		j = s.indexOf("</ele>");
		this.sele = (String) s.subSequence(i+5,j-2);
		this.ele = Double.valueOf(this.sele);
	}
	
	public void printTrackPoint(int i) {
		System.out.println("Track Point no."+i);
		System.out.println("lat: "+this.slat);
		System.out.println("lon: "+this.slon);
		System.out.println("ele: "+this.sele);
	}
	

}

